<#-- 自定义变量方法 ----------------------------------------------------------------------------------------------->
<#assign getText=localizedTextContext.getText>
<#assign getIntText=localizedTextContext.getIntText>
<#assign getLongText=localizedTextContext.getLongText>
<#include "/view/templates/bs-global.ftl">


<#--########################以下是CRUD相关宏##########################-->
<#-- index -->
<#macro content id='' title='' url=''>
<#assign url=url>
<@panel title=title>
	<@con fit=true>
		<@row>
			<#if navList>
			<ol class="breadcrumb">
			<li>首页</li>
			<#list navList as nav>
				<li>${nav}</li>
			</#list>
			</ol>
			</#if>
		</@row>
		<@row>
		<p>
		<#nested>
		</p>
		</@row>
		<#if url>
		<@row fit=true id="${id}bslist" data="url:${url}"></@row>
		</#if>
	</@con>
</@panel>
	
<script>
	 $(document).ready(function(){
   		var url = $('#${id}bslist').qdata().url;
		bfsu.list({id:'${id}',url:url});
    });
	
</script>
</#macro>
<#--query-->
<#macro query queryUrl="" id='' showButton=true>
    <#if queryUrl=="">
        <#local queryUrl=url>
    </#if>
    <@row id='${id}query'>
    	<form class="form-inline" name="${id}queryForm" id="${id}queryForm" action="${queryUrl}" method="POST">
    		<p>
            <#nested/>
            <#if showButton><@button icon="search" type="success" onclick="bfsu.query({id:'${id}'});">查询</@button></#if>
            </p>
        </form>
    </@row>
    <script>
    
    $(document).ready(function(){
   		bfsu.initQuery({id:'${id}'});
	    document.onkeydown = function(e){ 
			var ev = document.all ? window.event : e; 
			if(ev.keyCode==13) { 
				bfsu.query({id:'${id}',url:'${queryUrl}'});
			} 
		} 
    });
    </script>
</#macro>
<#-- 列表宏 -->
<#--
 id 区分页面不同list标识
 importTable 是否生成<table>标签
 page 后端数据封装对象名称
 islitepage 是否显示精简版分页
  -->
<#macro list id='' importTable=true page=page islitepage=false>
	<#if importTable>
		<@table>
			<#nested>
		</@table>
	<#else>
		<#nested>
	</#if>
	<#if page!="">
	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"></div>
		<#if page.items?size gt 0>
		<#if islitepage>
		<@paginationlite id=id page=page></@paginationlite>	
		<#else>
		<@pagination id=id page=page></@pagination>
		</#if>
		<#else>
		<ol class="breadcrumb">
	  		<li>没有数据！</li>
		</ol>
		</#if>
	</#if>
</#macro>

<#-- pagination -->
<#macro pagination page id=''>
	<div class="col-xs-6 col-sm-6 col-md-6 col-lg-4" style='padding-left:0px;padding-right:0px;'>
		<div class="input-group">
			<span class="input-group-addon">第</span>
			<input type="text" class="form-control crudpage" value="${page.currentPage}">
			<span class="input-group-addon">页每页</span>
			<input type="text" class="form-control crudsize" value="${page.pageSize}">
			<span class="input-group-addon">条</span>
		</div>
	</div>
	<div class="col-xs-6 col-sm-6 col-md-6 col-lg-2" style='padding-left:0px;padding-right:0px;'>
		<div class="input-group"><span class="input-group-addon">共${page.totalRecord}条${page.totalPage}页</span>
			<button type="button" class="btn btn-primary" onclick="javascript:bfsu.go({id:'${id}'});">GO</button>
			
		</div>
	</div>
	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-6" style='padding-left:0px;padding-right:0px;'>
		<ul class="pagination" style="margin:0;">
			<#assign pagenum = page.totalPage>
			<#if pagenum gt 1>
				<li <#if page.currentPage == 1>class="disabled"</#if>>
					<a href="javascript:bfsu.page({id:'${id}',currentPage:1});" class="crud crudfirst">
						<@bsicon icon="step-backward"/>
					</a>
				</li>
				<li <#if page.currentPage == 1>class="disabled"</#if>>
					<a href="javascript:bfsu.page({id:'${id}',currentPage:${page.currentPage-1}});" class="crud crudprev">
						<@bsicon icon="chevron-left"/>
					</a>
				</li>
				<#if pagenum lte 3>
					<#list 1..pagenum as pn>
						<li <#if page.currentPage == pn>class="active"</#if>>
							<a href="javascript:bfsu.page({id:'${id}',currentPage:${pn}});" class="cruda">${pn}</a>
						</li>
					</#list>
				</#if>
				<#if pagenum gt 3>
					<#if page.currentPage lt 2>
						<#list 1..pagenum as pn>
							<#if pn lt 3>
								<li <#if page.currentPage == pn>class="active"</#if>>
									<a href="javascript:bfsu.page({id:'${id}',currentPage:${pn}});" class="cruda">${pn}</a>
								</li>
							</#if>
								
						</#list>
					</#if>
					<#if page.currentPage gte 2>
						<#if page.currentPage-1 gt 0>
							<li class="disabled">
								<a href="javascript:void(0);">...</a>
							</li>
							
						</#if>
						<#list 1..pagenum as pn>
							<#if (page.currentPage-1 <= pn)&&(pn <= page.currentPage+1)>
								<li <#if page.currentPage == pn>class="active"</#if>>
									<a href="javascript:bfsu.page({id:'${id}',currentPage:${pn}});" class="cruda">${pn}</a>
								</li>
							</#if>
								
						</#list>
					</#if>
					<#if page.currentPage+1 lt pagenum>
						<li class="disabled">
							<a href="javascript:void(0);">...</a>
						</li>
					</#if>
				</#if>
				
				<li <#if page.currentPage == pagenum>class="disabled"</#if>>
					<a href="javascript:bfsu.page({id:'${id}',currentPage:${page.currentPage+1}});" class="crud crudnext">
						<@bsicon icon="chevron-right"/>
					</a>
				</li>
				<li	<#if page.currentPage == pagenum>class="disabled"</#if>>
					<a href="javascript:bfsu.page({id:'${id}',currentPage:${page.totalPage}});" class="crud crudlast" data="page:${pagenum}">
						<@bsicon icon="step-forward"/>
					</a>
				</li>
			</#if>
		</ul>
	</div>
</#macro>
<#-- 精简分页宏 -->
<#macro paginationlite page id=''>
	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style='padding-left:0px;padding-right:0px;'>
			<input type="hidden" class="crudpage" value="${page.currentPage}">
			<input type="hidden" class="crudsize" value="${page.pageSize}">
		<ul class="pagination pagination-sm" style="margin:0;">
			<#assign pagenum = page.totalPage>
			<#if pagenum gt 1>
				<li <#if page.currentPage == 1>class="disabled"</#if>>
					<a href="javascript:bfsu.page({id:'${id}',currentPage:1});" class="crud crudfirst">
						<@bsicon icon="step-backward"/>
					</a>
				</li>
				<li <#if page.currentPage == 1>class="disabled"</#if>>
					<a href="javascript:bfsu.page({id:'${id}',currentPage:${page.currentPage-1}});" class="crud crudprev">
						<@bsicon icon="chevron-left"/>
					</a>
				</li>
				<#if pagenum lte 3>
					<#list 1..pagenum as pn>
						<li <#if page.currentPage == pn>class="active"</#if>>
							<a href="javascript:bfsu.page({id:'${id}',currentPage:${pn}});" class="cruda">${pn}</a>
						</li>
					</#list>
				</#if>
				<#if pagenum gt 3>
					<#if page.currentPage lt 2>
						<#list 1..pagenum as pn>
							<#if pn lt 3>
								<li <#if page.currentPage == pn>class="active"</#if>>
									<a href="javascript:bfsu.page({id:'${id}',currentPage:${pn}});" class="cruda">${pn}</a>
								</li>
							</#if>
								
						</#list>
					</#if>
					<#if page.currentPage gte 2>
						<#if page.currentPage-1 gt 0>
							<li class="disabled">
								<a href="javascript:void(0);">...</a>
							</li>
							
						</#if>
						<#list 1..pagenum as pn>
							<#if (page.currentPage-1 <= pn)&&(pn <= page.currentPage+1)>
								<li <#if page.currentPage == pn>class="active"</#if>>
									<a href="javascript:bfsu.page({id:'${id}',currentPage:${pn}});" class="cruda">${pn}</a>
								</li>
							</#if>
								
						</#list>
					</#if>
					<#if page.currentPage+1 lt pagenum>
						<li class="disabled">
							<a href="javascript:void(0);">...</a>
						</li>
					</#if>
				</#if>
				
				<li <#if page.currentPage == pagenum>class="disabled"</#if>>
					<a href="javascript:bfsu.page({id:'${id}',currentPage:${page.currentPage+1}});" class="crud crudnext">
						<@bsicon icon="chevron-right"/>
					</a>
				</li>
				<li	<#if page.currentPage == pagenum>class="disabled"</#if>>
					<a href="javascript:bfsu.page({id:'${id}',currentPage:${page.totalPage}});" class="crud crudlast" data="page:${pagenum}">
						<@bsicon icon="step-forward"/>
					</a>
				</li>
			</#if>
		</ul>
	</div>
</#macro>
<#-- input -->
<#macro input id='' url=''>
	<form id="${id}inputForm" name="${id}inputForm" class="form-horizontal" role="form" action="${url}">
		<#nested>
	</form>
	<script type="text/javascript">
        bfsu.initInput({id:'${id}'});
     </script>
</#macro>